package com.yatang.yiliao.app.utils;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import com.yatang.yiliao.app.MyApp;
import com.yatang.yiliao.app.activities.LoginActivity;
import com.yatang.yiliao.app.model.User;


public class UserHttpClass{

	private static UserHttpClass instance = null;
	public static UserHttpClass newInstance(){
		if(instance == null){
			instance = new UserHttpClass();
		}
		return instance;
	}
	private UserHttpClass(){}
	
	
	public void loginUser(Context context,Handler handler,String uName,String uPass){
		Message msg = new Message();
		msg.what = LoginActivity.MSG_WHAT_CHECK_LOGIN_USER;
		msg.obj = false;
		for(User u : DataProvider.getTestUserData()){
			if(uName.equals(u.getUsername()) && uPass.equals(u.getPasswd())){
				msg.obj = true;
				MyApp myApp = (MyApp) context.getApplicationContext();
				myApp.globelUser = u;
				handler.sendMessage(msg);
				break;
			}
		}
	}
}
